<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>意向入驻列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div id="aaa"></div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">意向入驻列表</div>
                <div class="layui-card-body">
                    <div class="layui-form-item layui-form">
                        <div class="layui-inline">
                            <label class="layui-form-label">商铺类型</label>
                            <div class="layui-input-block">
                                <!-- <input type="text" name="type" id="type" placeholder="请输入" autocomplete="off" class="layui-input"> 1景点2酒店3美食4旅行社-->
                                  <select name="type" lay-filter="aihao" id="type">
                                    <option value=""></option>
                                    <option value="1">景点</option>
                                    <option value="2">酒店</option> 
                                    <option value="3">美食</option> 
                                    <option value="4">旅行社</option> 
                                </select>
                            </div>
                        </div> 
                        <div class="layui-inline">
                            <label class="layui-form-label">申请时间</label>
                            <div class="layui-input-block">
                                <input type="text" name="create_time" id="test6" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">处理状态</label>
                            <div class="layui-input-block">
                                <select name="status" lay-filter="aihao" id="status">
                                    <option value=""></option>
                                    <option value="0">未处理</option>
                                    <option value="1">已处理</option> 
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-btn-group test-table-operate-btn">
                                <button class="layui-btn" data-type="searchUserButton">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                    <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate">
                    </table>
                    <script type="text/html" id="test-table-operate-barDemo">  
                        {{# if(d.status==0){ }}
                        <a class="layui-btn layui-bg-green layui-btn-xs" lay-event="yesPass">处理</a>
                        {{# }else if(d.status==1){ }}
                        <a class=" layui-btn layui-btn-disabled layui-btn-xs">已处理</a> 
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="contentShow" style="display:none;padding: 30px;">
    <p id="consultation"></p>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.use('laydate', function(){
  var laydate = layui.laydate;  
  //日期范围
  laydate.render({
    elem: '#test6'
    ,range: true
  }); 
});  
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate','set'], function(){
        $ = layui.jquery;
        var table = layui.table
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form;

        table.render({
            elem: '#test-table-operate'
            ,url: "{:url('Intention/shoplist')}"
            ,height: 'full-100'
            ,cols: [[
                {field:'id',width:80,align:'center', title: 'ID'}
                ,{field:'type',align:'center',title: '商户类型'}
                ,{field:'user_name',align:'center',title: '申请人'}
                ,{field:'user_tel',align:'center',title: '商户电话'}
                ,{field:'store_name',align:'center',title: '商户名称'}
                ,{field:'create_time', align:'center', title: '申请时间'} 
                ,{align:'center',width:450, title: '操作', toolbar: '#test-table-operate-barDemo'}
            ]]
            ,page:true
            ,limit:20
        });

        form.render(null,'component-form-group');

        laydate.render({
            elem: '#search_time'
        });

        //监听工具条
        table.on('tool(test-table-operate)', function(obj){
            var data = obj.data;
            if(obj.event === 'team_legel_image'){
                if (!data.team_legel_image){
                    layer.msg('暂无图片',{time:1000});
                    return false;
                }
                var img_src = data.team_legel_image;
                var img_src_arr = img_src.split(',');

                var img_src_data = {};
                img_src_data.title = '法人正面照';
                img_src_data.id = data.id;
                img_src_data.start = 0;
                img_src_data.data =[];

                var src = {};

                for(var i=0;i<img_src_arr.length;i++){
                    src = {};
                    var num = i+1;
                    src.alt = '法人正面照'+ num;
                    src.pid = i;
                    src.src = img_src_arr[i];
                    src.thumb = img_src_arr[i];
                    console.log(src);
                    img_src_data.data.push(src);
                }
                console.log(img_src_data);
                layer.photos({
                    photos: img_src_data
                    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                });
            } else if(obj.event === 'team_license_image'){
                if (!data.team_license_image){
                    layer.msg('暂无图片',{time:1000});
                    return false;
                }
                var img_src = data.team_license_image;
                var img_src_arr = img_src.split(',');

                var img_src_data = {};
                img_src_data.title = '营业执照';
                img_src_data.id = data.id;
                img_src_data.start = 0;
                img_src_data.data =[];

                var src = {};

                for(var i=0;i<img_src_arr.length;i++){
                    src = {};
                    var num = i+1;
                    src.alt = '营业执照'+ num;
                    src.pid = i;
                    src.src = img_src_arr[i];
                    src.thumb = img_src_arr[i];
                    console.log(src);
                    img_src_data.data.push(src);
                }
                layer.photos({
                    photos: img_src_data
                    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                });
            }else if(obj.event === 'team_image'){
                if (!data.team_image){
                    layer.msg('暂无图片',{time:1000});
                    return false;
                }
                var img_src = data.team_image;
                var img_src_arr = img_src.split(',');

                var img_src_data = {};
                img_src_data.title = '店铺实景';
                img_src_data.id = data.id;
                img_src_data.start = 0;
                img_src_data.data =[];

                var src = {};

                for(var i=0;i<img_src_arr.length;i++){
                    src = {};
                    var num = i+1;
                    src.alt = '店铺实景'+ num;
                    src.pid = i;
                    src.src = img_src_arr[i];
                    src.thumb = img_src_arr[i];
                    console.log(src);
                    img_src_data.data.push(src);
                }
                layer.photos({
                    photos: img_src_data
                    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                });
            }else if(obj.event === 'yesPass'){  
                 layer.confirm('确认已处理改条信息？', {
                      btn: ['确定','取消'] //按钮
                    }, function(){  
                         $.ajax({
                            url: "{:url('Intention/dispose')}",
                            type: 'post',
                            dataType: 'json',
                            data: {id:data.id},
                            success: function(msg){  
                                if (msg === 0) {  
                                    layer.msg('已处理', {icon: 1, time: 1000},function(){
                                        window.location.reload();
                                    });
                                }else{
                                    layer.msg('系统错误',{icon:2,time:1000});
                                }
                            }
                        });
                    }, function(){layer.closeAll();
                    });  
            }

        });

        var $ = layui.$, active = {
            searchUserButton:function(){
                var type  = $('#type').val();
                var create_time = $('#test6').val();
                var status = $('#status').val();

                table.reload('test-table-operate', {
                    where: {
                        type:type,
                        create_time: create_time,
                        status:status
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
                //return false;
            }
        };
        //绑定点击事件
        $('.test-table-operate-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>